package org.dfzt.modules.online.cgform.util;

import java.io.UnsupportedEncodingException;
import java.math.BigDecimal;
import java.net.InetAddress;
import java.net.NetworkInterface;
import java.net.SocketException;
import java.net.UnknownHostException;
import java.util.Collection;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;


class l {
    static Map<String, Object> a = new HashMap();


    public static Map<String, Object> a() {
        return a;
    }


    public static boolean a(Object paramObject) {
        if (paramObject == null) {
            return true;
        }
        if (paramObject.equals("")) {
            return true;
        }
        if (paramObject.equals("null")) {
            return true;
        }
        return false;
    }


    public static boolean b(Object paramObject) {
        if (paramObject == null)
            return true;
        if (paramObject instanceof CharSequence)
            return (((CharSequence) paramObject).length() == 0);
        if (paramObject instanceof Collection)
            return ((Collection) paramObject).isEmpty();
        if (paramObject instanceof Map)
            return ((Map) paramObject).isEmpty();
        if (paramObject instanceof Object[]) {
            Object[] arrayOfObject = (Object[]) paramObject;
            if (arrayOfObject.length == 0) {
                return true;
            }
            boolean bool = true;
            for (byte b = 0; b < arrayOfObject.length; b++) {
                if (!b(arrayOfObject[b])) {
                    bool = false;
                    break;
                }
            }
            return bool;
        }
        return false;
    }

    public static boolean c(Object paramObject) {
        if (paramObject != null && !paramObject.equals("") && !paramObject.equals("null")) {
            return true;
        }
        return false;
    }


    public static String a(String paramString1, String paramString2, String paramString3) {
        return c(paramString1, paramString2, paramString3);
    }


    public static String b(String paramString1, String paramString2, String paramString3) {
        paramString1 = "";
        try {
            paramString1 = new String(paramString1.getBytes("ISO-8859-1"), "GBK");
        } catch (UnsupportedEncodingException unsupportedEncodingException) {

            unsupportedEncodingException.printStackTrace();
        }
        return paramString1;
    }


    private static String c(String paramString1, String paramString2, String paramString3) {
        String str = null;
        if (paramString1 == null || paramString1.trim().equals(""))
            return paramString1;
        try {
            byte[] arrayOfByte = paramString1.getBytes(paramString2);
            for (byte b = 0; b < arrayOfByte.length; b++) {
                System.out.print(arrayOfByte[b] + "  ");
            }
            str = new String(arrayOfByte, paramString3);
        } catch (Exception exception) {
            exception.printStackTrace();
            return null;
        }
        return str;
    }

    public static int a(String paramString, int paramInt) {
        if (paramString == null || paramString == "") {
            return paramInt;
        }
        try {
            return Integer.parseInt(paramString);
        } catch (NumberFormatException numberFormatException) {
            return paramInt;
        }
    }

    public static int a(String paramString) {
        if (paramString == null || paramString == "") {
            return 0;
        }
        try {
            return Integer.parseInt(paramString);
        } catch (NumberFormatException numberFormatException) {
            return 0;
        }
    }

    public static int d(Object paramObject) {
        if (paramObject == null || paramObject == "") {
            return 0;
        }
        try {
            return Integer.parseInt(paramObject.toString());
        } catch (NumberFormatException numberFormatException) {
            return 0;
        }
    }

    public static int a(String paramString, Integer paramInteger) {
        if (paramString == null || paramString == "") {
            return paramInteger.intValue();
        }
        try {
            return Integer.parseInt(paramString);
        } catch (NumberFormatException numberFormatException) {
            return 0;
        }
    }

    public static Integer[] a(String[] paramArrayOfString) {
        Integer[] arrayOfInteger = new Integer[paramArrayOfString.length];
        if (paramArrayOfString == null) {
            return null;
        }
        for (byte b = 0; b < paramArrayOfString.length; b++) {
            arrayOfInteger[b] = Integer.valueOf(Integer.parseInt(paramArrayOfString[b]));
        }
        return arrayOfInteger;
    }


    public static double a(String paramString, double paramDouble) {
        if (paramString == null || paramString == "") {
            return paramDouble;
        }
        try {
            return Double.parseDouble(paramString);
        } catch (NumberFormatException numberFormatException) {
            return paramDouble;
        }
    }

    public static double a(Double paramDouble, double paramDouble1) {
        if (paramDouble == null) {
            return paramDouble1;
        }
        return paramDouble.doubleValue();
    }

    public static int a(Object paramObject, int paramInt) {
        if (a(paramObject)) {
            return paramInt;
        }
        try {
            return Integer.parseInt(paramObject.toString());
        } catch (NumberFormatException numberFormatException) {
            return paramInt;
        }
    }

    public static int a(BigDecimal paramBigDecimal, int paramInt) {
        if (paramBigDecimal == null) {
            return paramInt;
        }
        return paramBigDecimal.intValue();
    }

    public static Integer[] b(String[] paramArrayOfString) {
        int i = paramArrayOfString.length;
        Integer[] arrayOfInteger = new Integer[i];
        try {
            for (byte b = 0; b < i; b++) {
                arrayOfInteger[b] = new Integer(paramArrayOfString[b].trim());
            }
            return arrayOfInteger;
        } catch (NumberFormatException numberFormatException) {
            return null;
        }
    }


    public static String b(String paramString) {
        return a(paramString, "");
    }


    public static String e(Object paramObject) {
        if (a(paramObject)) {
            return "";
        }
        return paramObject.toString().trim();
    }


    public static String a(int paramInt) {
        return String.valueOf(paramInt);
    }


    public static String c(String[] paramArrayOfString) {
        if (paramArrayOfString.length == 0) {
            return "";
        }
        String str = "";
        for (String str1 : paramArrayOfString) {
            str = str + ",'" + str1 + "'";
        }
        return str.substring(1);
    }


    public static String a(float paramFloat) {
        return String.valueOf(paramFloat);
    }


    public static String a(String paramString1, String paramString2) {
        if (a((Object)paramString1)) {
            return paramString2;
        }
        return paramString1.trim();
    }

    public static String a(Object paramObject, String paramString) {
        if (a(paramObject)) {
            return paramString;
        }
        return paramObject.toString().trim();
    }

    public static long c(String paramString) {
        Long x =new Long(0L);
        try {
            x =Long.valueOf(paramString);
        } catch (Exception exception) {
        }

        return x.longValue();
    }


    public static String b() {
        String str = null;
        try {
            InetAddress inetAddress = InetAddress.getLocalHost();
            str = inetAddress.getHostAddress();
        } catch (UnknownHostException unknownHostException) {
            unknownHostException.printStackTrace();
        }
        return str;
    }


    private static boolean a(Class paramClass) throws Exception {
        return (paramClass.equals(String.class) || paramClass.equals(Integer.class) || paramClass.equals(Byte.class) || paramClass.equals(Long.class) || paramClass.equals(Double.class) || paramClass.equals(Float.class) || paramClass.equals(Character.class) || paramClass.equals(Short.class) || paramClass.equals(BigDecimal.class) || paramClass.equals(java.math.BigInteger.class) || paramClass.equals(Boolean.class) || paramClass.equals(java.util.Date.class) || paramClass.isPrimitive());
    }


    public static String c() throws SocketException {
        String str1 = null;
        String str2 = null;

        Enumeration enumeration = NetworkInterface.getNetworkInterfaces();
        InetAddress inetAddress = null;
        boolean bool = false;
        while (enumeration.hasMoreElements() && !bool) {
            NetworkInterface networkInterface = (NetworkInterface) enumeration.nextElement();
            Enumeration enumeration1 = networkInterface.getInetAddresses();
            while (enumeration1.hasMoreElements()) {
                inetAddress = (InetAddress) enumeration1.nextElement();
                if (!inetAddress.isSiteLocalAddress() && !inetAddress.isLoopbackAddress() && inetAddress.getHostAddress().indexOf(":") == -1) {
                    str2 = inetAddress.getHostAddress();
                    bool = true;
                    break;
                }
                if (inetAddress.isSiteLocalAddress() && !inetAddress.isLoopbackAddress() && inetAddress.getHostAddress().indexOf(":") == -1) {
                    str1 = inetAddress.getHostAddress();
                }
            }
        }

        if (str2 != null && !"".equals(str2)) {
            return str2;
        }
        return str1;
    }


    public static String d(String paramString) {
        String str = "";
        if (paramString != null) {
            Pattern pattern = Pattern.compile("\\s*|\t|\r|\n");
            Matcher matcher = pattern.matcher(paramString);
            str = matcher.replaceAll("");
        }
        return str;
    }


    public static boolean a(String paramString, String[] paramArrayOfString) {
        if (paramArrayOfString == null || paramArrayOfString.length == 0) {
            return false;
        }
        for (byte b = 0; b < paramArrayOfString.length; b++) {
            String str = paramArrayOfString[b];
            if (str.equals(paramString)) {
                return true;
            }
        }
        return false;
    }


    public static boolean b(String paramString1, String paramString2) {
        String[] arrayOfString = null;
        if (paramString2 != null) {
            arrayOfString = paramString2.split(",");
        }
        return a(paramString1, arrayOfString);
    }


    public static Map<Object, Object> d() {
        return new HashMap();
    }


    /*public static Map<Object, Object> a(Set<Object> paramSet) {
        Map<Object,Object> map = d();
        for (Map.Entry entry : paramSet) {
            map.put(entry.getKey().toString(), (entry.getValue() == null) ? "" : entry.getValue().toString().trim());
        }
        return map;
    }*/


    public static boolean e(String paramString) {
        long l1 = f(paramString);
        long l2 = f("10.0.0.0");
        long l3 = f("10.255.255.255");
        long l4 = f("172.16.0.0");
        long l5 = f("172.31.255.255");
        long l6 = f("192.168.0.0");
        long l7 = f("192.168.255.255");
        return (a(l1, l2, l3) || a(l1, l4, l5) || a(l1, l6, l7) || paramString.equals("127.0.0.1"));
    }


    private static long f(String paramString) {
        String[] arrayOfString = paramString.split("\\.");
        long l1 = Integer.parseInt(arrayOfString[0]);
        long l2 = Integer.parseInt(arrayOfString[1]);
        long l3 = Integer.parseInt(arrayOfString[2]);
        long l4 = Integer.parseInt(arrayOfString[3]);

        return l1 * 256L * 256L * 256L + l2 * 256L * 256L + l3 * 256L + l4;
    }


    private static boolean a(long paramLong1, long paramLong2, long paramLong3) {
        return (paramLong1 >= paramLong2 && paramLong1 <= paramLong3);
    }
}
